package com.example.demo.Controller;
import com.example.demo.Repository.UserRepo;
import com.example.demo.Entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;


@RestController
@RequestMapping("/index")//页面的url地址
@CrossOrigin(origins = "*")//允许所有同源访问，防止出现跨域问题
public class TestController {
    @Autowired
    public UserRepo up;
    @GetMapping
    public Optional<User> getindex()//对应函数
    {
        return up.findByUsername("Alice Smith");
    }


}
